import {ApiData, MyConfig, MySite} from "@/interfaces/apiResponse.ts";
import myAxios from "@/plugins/axios";

export default ()=>{
    const config = ref<MyConfig>();
    const getConfig = async (fieldName:any)=>{
        const res = await myAxios.request<ApiData<MyConfig>>({
            url:`get_config/${fieldName}`,
        });
        config.value = res.data;
    }
    const setConfig = async (fieldName:any,data:any)=>{

        const res =  await myAxios.request<ApiData<MySite>>({
            url:`config/${fieldName}`,
            method:'PUT',
            data
        });
        config.value = res.data;
    }
    return {config,getConfig,setConfig}
}